package com.practice.java8.lambdascope;

import com.practice.java8.functionalinterface.Converter;

public class LambdaScopeMain {

	public static void main(String[] args) {
		TestScope testScope = new TestScope();
		testScope.testLocalScope();
		testScope.testFieldScope();
		testScope.testStaticScope();
	}

}

class TestScope {
	private static int staticNum;
	private int num;

	public void testLocalScope() {
		int num = 1;
		Converter<Integer, String> converter = (from) -> String.valueOf(from
				+ num);
		// num = 2;
		String converted = converter.convert(10);
		System.out.println(converted);
	}

	public void testFieldScope() {
		num = 1;
		Converter<Integer, String> converter = (from) -> String.valueOf(from
				+ num);
		num = 2;
		String converted = converter.convert(10);
		System.out.println(converted);
	}

	public void testStaticScope() {
		staticNum = 1;
		Converter<Integer, String> converter = (from) -> String.valueOf(from
				+ staticNum);
		staticNum = 2;
		String converted = converter.convert(10);
		System.out.println(converted);
	}
}